//package com.zxl.grocery.config;
//
//import org.quartz.ee.servlet.QuartzInitializerListener;
//import org.springframework.beans.factory.config.PropertiesFactoryBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
//
//import javax.sql.DataSource;
//import java.io.IOException;
//import java.util.Properties;
//
///**
// * quartz定时器配置文件
// * @Author: zxl
// * @Description:
// * @Date: Created in 22:57 2017/8/17
// * @Modified By:
// */
//@Configuration
//public class SchedulerConfig {
//
//    @Bean
//    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) throws IOException {
//        SchedulerFactoryBean factory = new SchedulerFactoryBean();
//        factory.setQuartzProperties(quartzProperties());
//
//
//      //  factory.setSchedulerName("GroceryQuartzScheduler");
//
//        //延时启动
//        factory.setStartupDelay(30);
//        //是org.springframework.scheduling.quartz.SchedulerFactoryBean这个类中把spring上下 文以key/value的方式存放在了quartz的上下文中了。能够用applicationContextSchedulerContextKey所定义的key得到相应的spring上下文
//        factory.setApplicationContextSchedulerContextKey("applicationContextKey");
//        //可选，QuartzScheduler 启动时更新己存在的Job，这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
//        factory.setOverwriteExistingJobs(true);
//        //设置自动启动，默认为true
//        factory.setAutoStartup(true);
//        return factory;
//    }
//
//    @Bean
//    public Properties quartzProperties() throws IOException {
//        PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
//        propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
//        return propertiesFactoryBean.getObject();
//    }
//
//    @Bean
//    public QuartzInitializerListener executorListener() {
//        return new QuartzInitializerListener();
//    }
////    @Bean
////    public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
////        SchedulerFactoryBean factory = new SchedulerFactoryBean();
////        factory.setDataSource(dataSource);
////
////        //quartz参数
////        Properties prop = new Properties();
////        prop.put("org.quartz.scheduler.instanceName", "RenrenScheduler");
////        prop.put("org.quartz.scheduler.instanceId", "AUTO");
////        //线程池配置
////        prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
////        prop.put("org.quartz.threadPool.threadCount", "20");
////        prop.put("org.quartz.threadPool.threadPriority", "5");
////        //JobStore配置
////        prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
////        //集群配置
////        prop.put("org.quartz.jobStore.isClustered", "true");
////        prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
////        prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
////
////        prop.put("org.quartz.jobStore.misfireThreshold", "12000");
////        prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
////        factory.setQuartzProperties(prop);
////
////        factory.setSchedulerName("RenrenScheduler");
////        //延时启动
////        factory.setStartupDelay(30);
////        factory.setApplicationContextSchedulerContextKey("applicationContextKey");
////        //可选，QuartzScheduler 启动时更新己存在的Job，这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
////        factory.setOverwriteExistingJobs(true);
////        //设置自动启动，默认为true
////        factory.setAutoStartup(true);
////
////        return factory;
////    }
//}
